#!/bin/bash

# =======================================================
# postbuild.sh usage:
#     
#     $1 = top (where src is)
#     $2 = type (retail debug, or both)
#     $3 = title (jobname)
#     $4 = buildnumber (title.version+p4 change)
# =======================================================

export BuildRoot=$1
export BuildType=$2
export BuildTitle=$3
export BuildNum=$4

export OutputDir=/usr/builds/$BuildTitle/$BuildNum

retail() {
    mkdir -p $OutputDir/retail
    cp $BuildRoot/generated $OutputDir/retail
}

debug() {
    mkdir -p $OutputDir/debug
    cp $BuildRoot/generated $OutputDir/debug
}

if [ "$BuildType" = "retail" ]
then
    retail
fi

if [ "$BuildType" = "debug" ]
then
    debug
fi

if [ "$BuildType" = "both" ]
then
    retail
    debug
fi

#
# Run whatever is required to handle postbuild steps
#
mkdir -p $OutputDir

cp -r generated/* $OutputDir
